﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SqlMiM.Common.ViewModel;
using System.Data.SqlClient;
using SqlMiM.Common.Model;

namespace SqlMiM
{
    /// <summary>
    /// Interaction logic for LoginWindow.xaml
    /// </summary>
    public partial class LoginWindow : Window
    {
        public LoginWindow()
        {
            InitializeComponent();
        }

        protected override void OnClosed(EventArgs e)
        {
        }

        /// <summary>
        /// New ShowDialog method. Returns new SqlConnectionStringBuilder and new Server object
        /// </summary>
        public bool? ShowDialog(out SqlConnectionStringBuilder sqlConnectionStringBuilder, out Server server)
        {
            bool? result = this.ShowDialog();

            if (result.HasValue && result.Value)
            {
                sqlConnectionStringBuilder = this.ServerLoginView.ServerLoginViewModel.SqlConnectionStringBuilder;
                server = this.ServerLoginView.ServerLoginViewModel.ServerConnection;

                result = this.ServerLoginView.ServerLoginViewModel.IsValid;
            }
            else
            {
                sqlConnectionStringBuilder = null;
                server = null;
            }

            return result;
        }
        
       
    }
}
